# -*- coding: utf-8 -*-
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404

__author__ = 'Junior Lima'
from django.shortcuts import render_to_response
from evento.forms import PessoaForm, InscricaoForm
from evento.models import Evento, Responsavel, Palestrante

def inicial(request, slugevento):
    headerinicial = True
    eventoget = Evento.objects.get(slugevento=slugevento)
    responsavel = Responsavel.objects.filter(evento=eventoget)
    return render_to_response('evento/index.html', locals(), context_instance = RequestContext(request))

def apresentacao(request, slugevento):
    eventoget = Evento.objects.get(slugevento=slugevento)
    responsavel = Responsavel.objects.filter(evento=eventoget)
    return render_to_response('evento/apresentacao.html', locals(), context_instance = RequestContext(request))

def palestrante(request, slugevento):
    eventoget = Evento.objects.get(slugevento=slugevento)
    responsavel = Responsavel.objects.filter(evento=eventoget)
    palestrante = Palestrante.objects.filter(evento=eventoget)
    return render_to_response('evento/palestrante.html', locals(), context_instance = RequestContext(request))

def programacao(request, slugevento):
    evento = Evento.objects.get(slugevento=slugevento)
    return render_to_response('evento/programacao.html', locals(), context_instance = RequestContext(request))

def inscricao(request, slugevento):
    evento = Evento.objects.get(slugevento=slugevento)
    if request.method=='POST':
        formp = PessoaForm(request.POST)
        formi = InscricaoForm(request.POST)

        if formp.is_valid() and formi.is_valid():
            pes = formp.save()
            ins = formi.save(pes, evento)
            ins.save()
            return render_to_response('evento/concluido.html', locals(), context_instance = RequestContext(request))
    else:
        formp = PessoaForm
        formi = InscricaoForm
    return render_to_response('evento/cadastrar.html', locals(), context_instance = RequestContext(request))

def local(request, slugevento):
    evento = Evento.objects.get(slugevento=slugevento)
    return render_to_response('evento/local.html', locals(), context_instance = RequestContext(request))

def contato(request, slugevento):
    evento = Evento.objects.get(slugevento=slugevento)
    return render_to_response('evento/contato.html', locals(), context_instance = RequestContext(request))